/**
 * 
 */
package com.lazyshopkeeper.front.apiService.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lazyshopkeeper.front.apiService.IUserService;
import com.lazyshopkeeper.front.common.Constant;
import com.taobao.api.ApiException;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.User;
import com.taobao.api.request.UserSellerGetRequest;
import com.taobao.api.response.UserSellerGetResponse;

/**
 * @author xuyuqi
 *
 */
@Service
public class UserService implements IUserService {

	@Autowired
	private TaobaoClient client;
	
	@Override
	public User getCurrentUser(String sessionKey) throws ApiException {
		UserSellerGetRequest req = new UserSellerGetRequest();
		req.setFields(Constant.FIELDS_USER);
		UserSellerGetResponse response = client.execute(req, sessionKey);
		return response==null?null:response.getUser();
	}

}
